package com.cdp.web.controller.system;
import com.cdp.common.core.domain.AjaxResult;
import com.cdp.common.core.domain.entity.SysFileAudit;
import com.cdp.system.dto.AuditRequestDTO;
import com.cdp.system.service.ISysFileAuditService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 审核信息
 */
@RestController
@RequestMapping("/system/audit")
public class SysFileAuditController {


    @Autowired
    private ISysFileAuditService fileAuditService;

    /**
     * 中间表 测试用
     *
     * @return
     */
    @GetMapping("listFileAudits")
    private AjaxResult listFileAudits() {
        List<SysFileAudit> listFileAudits = fileAuditService.listFileAudits();
        return AjaxResult.success(listFileAudits);
    }





    /**
     * 管理员审核
     *
     * @return AjaxResult
     */
    @PostMapping("/audit")
    public AjaxResult updateAudit(@RequestBody AuditRequestDTO auditRequestDTO) {
        // 检查参数
        try {
            // 调用服务层更新审核
            return fileAuditService.updateAudit(auditRequestDTO);
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error("审核失败: " + e.getMessage());
        }
    }





}


